﻿/*
LICENCE___________________________________________________________________
    Copyright (C) 2012 Reverdy Sylvain

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
FIN LICENCE______________________________________________________________
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Merise_designer.Methodes
{
   public class M_Types
    {
        private Donnees.D_Type dType = new Donnees.D_Type();
        private List<Objets.CL_Type> m_objTypes = new List<Objets.CL_Type>();

        public List<Objets.CL_Type>  getAll()
        {
            return this.m_objTypes;
        }

        public Objets.CL_Type get(int id)
        {
            
            foreach(Objets.CL_Type t in m_objTypes)
            {
                if(t.id==id)
                {
                    return t;
                }
            }
            return null;
        }

        public void load()
        {
             foreach (System.Data.DataRow theRow in dType.getAllTypes("monjeu").Tables["monjeu"].Rows)
             {
                 m_objTypes.Add(new Objets.CL_Type(int.Parse(theRow["ID_TYPE"].ToString()),theRow["NOM_TYPE"].ToString()));
             }
        }
    }
}
